home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
c
/
cl_7_bug.zip
/
BUG_1.ERR
< prev
next >
Wrap
Text File
|
1992-10-10
|
12KB
|
403 lines
; Static Name Aliases
;
TITLE bug_1.c
.8087
INCLUDELIB LLIBCE
INCLUDELIB OLDNAMES.LIB
BUG_1_TEXT SEGMENT WORD PUBLIC 'CODE'
BUG_1_TEXT ENDS
_DATA SEGMENT WORD PUBLIC 'DATA'
_DATA ENDS
CONST SEGMENT WORD PUBLIC 'CONST'
CONST ENDS
_BSS SEGMENT WORD PUBLIC 'BSS'
_BSS ENDS
DGROUP GROUP CONST, _BSS, _DATA
ASSUME DS: DGROUP, SS: DGROUP
EXTRN __acrtused:ABS
EXTRN _printf:FAR
_DATA SEGMENT
$SG262 DB 'ALLOC', 00H
$SG263 DB 'ALLOCA', 00H
$SG264 DB 'get_filename returns: %d, Should return 5', 0aH, 00H
$SG275 DB 'A', 00H
_DATA ENDS
BUG_1_TEXT SEGMENT
ASSUME CS: BUG_1_TEXT
PUBLIC _main
_main PROC FAR
;|*** /*
;|*** Test if cl alias (?) bugg (there isn't any use of alias in this code)
;|*** or double loop variable bugg (two loops, if the first is removed it works)
;|*** */
;|***
;|*** #include <stdio.h>
;|***
;|*** typedef struct fileinfo /* Struct returned from my_dir & my_stat */
;|*** {
;|*** char *name;
;|*** } FILEINFO;
;|***
;|*** typedef struct my_dir /* Struct returned from my_dir */
;|*** {
;|*** struct fileinfo *dir_entry;
;|*** int number_off_files;
;|*** } MY_DIR;
;|***
;|*** void test_file(FILEINFO *test);
;|*** int get_filename(MY_DIR *dir_info);
;|***
;|*** /* This function breaks when compiling with
;|*** cl -Ox -AL.
;|*** Code breaks when using test_file() in loop
;|*** (possibly alias test in cl) and the result
;|*** is a loop of garbage. (se bugg_1.cod)
;|*** */
;|***
;|*** int main(int argc,char *argv[])
;|*** {
; Line 30
*** 000000 55 push bp
*** 000001 8b ec mov bp,sp
*** 000003 83 ec 24 sub sp,36 ;0024H
; argv = 8
; dir_info = -24
; fileinfo = -36
; argc = 6
;|*** MY_DIR dir_info;
;|*** FILEINFO fileinfo[3];
;|***
;|*** fileinfo[0].name="ALLOC";
; Line 34
*** 000006 c7 46 dc 00 00 mov WORD PTR [bp-36],OFFSET DGROUP:$SG262 ;fileinfo
*** 00000b 8c 5e de mov WORD PTR [bp-34],ds
;|*** fileinfo[1].name="ALLOCA";
; Line 35
*** 00000e c7 46 e0 06 00 mov WORD PTR [bp-32],OFFSET DGROUP:$SG263
*** 000013 8c 5e e2 mov WORD PTR [bp-30],ds
;|*** dir_info.dir_entry=fileinfo;
; Line 36
*** 000016 8d 46 dc lea ax,WORD PTR [bp-36] ;fileinfo
*** 000019 89 46 e8 mov WORD PTR [bp-24],ax ;dir_info
*** 00001c 8c 56 ea mov WORD PTR [bp-22],ss
;|*** dir_info.number_off_files=2;
; Line 37
*** 00001f c7 46 ec 02 00 mov WORD PTR [bp-20],2
;|***
;|*** printf("get_filename returns: %d, Should return 5\n",
;|*** get_filename(&dir_info));
; Line 40
*** 000024 8d 46 e8 lea ax,WORD PTR [bp-24] ;dir_info
*** 000027 16 push ss
*** 000028 50 push ax
*** 000029 9a 00 00 00 00 call FAR PTR _get_filename
*** 00002e 83 c4 04 add sp,4
*** 000031 50 push ax
*** 000032 b8 0d 00 mov ax,OFFSET DGROUP:$SG264
*** 000035 1e push ds
*** 000036 50 push ax
*** 000037 9a 00 00 00 00 call FAR PTR _printf
;|*** return(0);
; Line 41
*** 00003c 33 c0 xor ax,ax
;|*** }
; Line 42
*** 00003e 8b e5 mov sp,bp
*** 000040 5d pop bp
*** 000041 cb ret
_main ENDP
PUBLIC _get_filename
_get_filename PROC FAR
;|***
;|*** /* Expand inputed filename */
;|***
;|*** int get_filename(MY_DIR *dir_info)
;|*** {
; Line 47
*** 000042 55 push bp
*** 000043 8b ec mov bp,sp
*** 000045 83 ec 22 sub sp,34 ;0022H
*** 000048 57 push di
*** 000049 56 push si
; dir_info = 6
; i = -18
; k_length = -10
; count = -20
; part_name = -4
; pos = -8
; p_pos = -4
; best_info = -16
; j = -2
;|*** register int i;
;|*** int k_length;
;|*** unsigned int count;
;|*** char *part_name,*pos,*p_pos;
;|*** struct fileinfo *best_info;
;|***
;|*** part_name="A";
; Line 54
*** 00004a 8c 5e fe mov WORD PTR [bp-2],ds ;j
;|*** count=0; k_length= 1000;
; Line 55
*** 00004d c7 46 ec 00 00 mov WORD PTR [bp-20],0 ;count
*** 000052 c7 46 f6 e8 03 mov WORD PTR [bp-10],1000 ;03e8H ;k_length
;|***
;|*** for (i=0 ; i < dir_info->number_off_files ; i++)
; Line 57
*** 000057 c7 46 ee 00 00 mov WORD PTR [bp-18],0 ;i
*** 00005c c4 5e 06 les bx,DWORD PTR [bp+6] ;dir_info
*** 00005f 26 83 7f 04 00 cmp WORD PTR es:[bx+4],0
*** 000064 7f 03 jg $JCC100
*** 000066 e9 15 01 jmp $FB278
$JCC100:
*** 000069 c7 46 f4 00 00 mov WORD PTR [bp-12],0
$F276:
;|*** {
;|*** /* If next for-loop and test is removed the code works */
;|*** for (p_pos=part_name, pos=dir_info->dir_entry[i].name; *p_pos ;
;|*** pos++,p_pos++)
; Line 61
*** 00006e 26 c4 1f les bx,DWORD PTR es:[bx]
*** 000071 03 5e f4 add bx,WORD PTR [bp-12]
*** 000074 89 5e e8 mov WORD PTR [bp-24],bx
*** 000077 8c 46 ea mov WORD PTR [bp-22],es
*** 00007a 26 8b 07 mov ax,WORD PTR es:[bx]
*** 00007d 26 8b 57 02 mov dx,WORD PTR es:[bx+2]
*** 000081 8b f8 mov di,ax
*** 000083 bb 38 00 mov bx,OFFSET DGROUP:$SG275
*** 000086 8b f3 mov si,bx
*** 000088 8c 5e fe mov WORD PTR [bp-2],ds ;j
*** 00008b 80 3f 00 cmp BYTE PTR [bx],0
*** 00008e 74 0b je $FB281
*** 000090 8e c2 mov es,dx
$F279:
;|*** if (*pos != *p_pos)
; Line 62
*** 000092 26 8a 05 mov al,BYTE PTR es:[di]
*** 000095 38 04 cmp BYTE PTR [si],al
*** 000097 74 73 je $L313
$L312:
*** 000099 16 push ss
*** 00009a 1f pop ds
ASSUME DS: DGROUP
$FB281:
*** 00009b 8e 46 fe mov es,WORD PTR [bp-2] ;j
*** 00009e 26 80 3c 00 cmp BYTE PTR es:[si],0
*** 0000a2 74 03 je $JCC162
*** 0000a4 e9 c1 00 jmp $FC277
$JCC162:
;|*** break;
;|*** if (!*p_pos)
;|*** { /* In this example this is allways true */
;|*** if (count++)
; Line 66
*** 0000a7 8b 46 ec mov ax,WORD PTR [bp-20] ;count
*** 0000aa ff 46 ec inc WORD PTR [bp-20] ;count
*** 0000ad 0b c0 or ax,ax
*** 0000af 74 79 je $I284
;|*** {
;|*** register int j;
;|*** /* This loop will be garbage */
;|*** for (j=0 ; j < k_length ; j++)
; Line 70
*** 0000b1 33 ff xor di,di
*** 0000b3 89 7e fe mov WORD PTR [bp-2],di ;j
*** 0000b6 39 7e f6 cmp WORD PTR [bp-10],di ;k_length
*** 0000b9 7e 5f jle $L303
*** 0000bb c4 5e f0 les bx,DWORD PTR [bp-16] ;best_info
*** 0000be 26 8b 07 mov ax,WORD PTR es:[bx]
*** 0000c1 26 8b 57 02 mov dx,WORD PTR es:[bx+2]
*** 0000c5 89 46 e4 mov WORD PTR [bp-28],ax
*** 0000c8 89 56 e6 mov WORD PTR [bp-26],dx
*** 0000cb 8b f7 mov si,di
*** 0000cd 8b 7e f4 mov di,WORD PTR [bp-12]
*** 0000d0 8b cb mov cx,bx
*** 0000d2 8e 5e 08 mov ds,WORD PTR [bp+8]
ASSUME DS: NOTHING
$F286:
;|*** if (best_info->name[j] != dir_info->dir_entry[i].name[j])
; Line 71
; MONTY: LOOK AT THE FOLLOWING MESS (Without test_func() this is about 7 lines)
*** 0000d5 c4 5e e8 les bx,DWORD PTR [bp-24]
*** 0000d8 26 c4 1f les bx,DWORD PTR es:[bx]
; MONTY: THIS CODE DOES NOTHING >>
*** 0000db 8b c3 mov ax,bx
*** 0000dd 8c c2 mov dx,es
*** 0000df c4 5e e4 les bx,DWORD PTR [bp-28]
*** 0000e2 8e c2 mov es,dx
*** 0000e4 8b d8 mov bx,ax
; MONTY: THIS CODE DOES NOTHING << (dx:bx is reset later)
*** 0000e6 89 5e e0 mov WORD PTR [bp-32],bx
*** 0000e9 8c 46 e2 mov WORD PTR [bp-30],es
*** 0000ec c4 5e e4 les bx,DWORD PTR [bp-28]
*** 0000ef 8b c3 mov ax,bx
*** 0000f1 8c c2 mov dx,es
*** 0000f3 c4 5e e0 les bx,DWORD PTR [bp-32]
*** 0000f6 50 push ax
*** 0000f7 26 8a 00 mov al,BYTE PTR es:[bx][si]
*** 0000fa 58 pop ax
*** 0000fb 8e c2 mov es,dx
*** 0000fd 8b d8 mov bx,ax
*** 0000ff 26 8a 00 mov al,BYTE PTR es:[bx][si]
; MONTY: This should maybe be [bp-32], [bp-33] is definitely wrong
*** 000102 38 46 df cmp BYTE PTR [bp-33],al
*** 000105 74 1b je $L310
$L309:
*** 000107 16 push ss
*** 000108 1f pop ds
ASSUME DS: DGROUP
*** 000109 eb 12 jmp SHORT $FB288
*** 00010b 90 nop
$L313:
;|*** pos++,p_pos++)
; Line 61
*** 00010c 47 inc di
*** 00010d 46 inc si
*** 00010e 80 3c 00 cmp BYTE PTR [si],0
*** 000111 74 03 je $JCC27